import { useAuthStore } from "@/stores";


const auth = {
  mounted(el, binding) {
    const { value } = binding
    const authStore = useAuthStore()
    const currentPageRoles = authStore.authPermissionList ?? []
    if (value instanceof Array && value.length) {
      const hasPermission = value.every((item) =>
        currentPageRoles.includes(item),
      )
      if (!hasPermission) el.remove();
    } else {
      if (!currentPageRoles.includes(value)) el.remove();
    }
  },
}

export default auth